<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	/**
	* 
	*/
	class Test extends CI_Controller
	{
		function __construct()
		{
			parent::__construct();
			$this->load->helper('captcha');
			$this->load->library('form_validation');
            $this->load->library('pagination');
		}

		#生成验证码
		function code()
		{
			#调用函数生成验证码
			$vals = array('word_length' => 4,);
			$code = create_captcha($vals);
			
			$this->session->set_userdata('code',$code);
		}

		public function index()
		{
			$data['a'] = "a";
			//echo "hello world";
			/*$vals = array(
				'img_path' => FCPATH.'data/captcha/',
				'img_url'=> base_url('ci/data/captcha'),
				);*/
			$vals['img_path'] = BASE_DIR.'data/captcha/';
			$vals['img_url'] = SITE_URL.'data/captcha/';
			$vals['word'] = rand(10000,99999);
			//$data = $this->code();
			$data['a'] = base_url('aaa');
			//var_dump($data);
			$this->load->view('test',$data);
		}

        public function go()
        {
            echo time();
        }
        public function fenye($offset='')
        {
            #配置分页信息
            $config['base_url'] = SITE_URL.'index.php/test/fenye/';
            $config['total_rows'] = 100;//总数
            $config['per_page'] = 2;
            $config['uri_segment'] = 4;

            #自定义分页链接
            $config['first_link'] = 'first';
            $config['last_link'] = 'last';
            $config['prev_link'] = 'foren';
            $config['next_link'] = 'next';

            #初始化分页类
            $this->pagination->initialize($config);

            #生成分页信息
            $data['pageinfo'] = $this->pagination->create_links();

            $limit = $config['per_page'];
            //$data['goodstypes'] = $this->goodstype_model->list_goodstype($limit,$offset);

            header("charset='utf-8'");
            var_dump($data);
            //$this->load->view('goods_type_list.html',$data);
        }

		public function login()
		{
			//获取表单数据
			$getcode = $this->input->post('captcha');
			//echo $getcode;
			$code = strtolower($this->session->userdata('code'));
			//var_dump($this->session->all_userdata());
			$this->form_validation->set_rules('username','username','trim|required|xss_clean');
			$this->form_validation->set_rules('password','password','required|md5');
			$this->form_validation->set_rules('email','email','valid_email');
			//var_dump($this->form_validation->run());
			if($this->form_validation->run()  == TRUE)
			{
				$username = $this->input->post('username');
				$password = $this->input->post('password');
				$email = $this->input->post('email');
				echo $username.' '.$password.' '.$email;
			}
			
			if($getcode == $code)
			{
				$username = $this->input->post('username');
				$password = $this->input->post('password');
				echo $username.' '.$password;
			}
			else
			{
				//echo "seccess";
				//$this->index();
			}
		}
		public function ueditor()
		{
			//echo "";
			$this->load->view('ueditor');
		}

		public function ueditorget()
		{
			//echo $this->input->post('content');
			if($this->input->post('content') == '<p>aaa</p>')
			{
				echo "OK";
			}
			return;
		}
	}

?>